package com.ncp.model.dao;

import java.sql.Connection;
import java.sql.DriverManager;

public class DbConnection {
	
	public static Connection getConnByDataSource()
	{
		Connection conn=null;
//		String sourceURL = "jdbc:mysql://172.22.8.202/ncp";
//		String sourceURL = "jdbc:mysql://localhost:3306/greenfarm_dev";
//		String user = "root";
//		String password = "d24520";
		String sourceURL = "jdbc:mysql://greenfarm-mysql.cvkpb06l3ty7.ap-northeast-1.rds.amazonaws.com:3306/greenfarm";
		String user = "greenfarm";
		String password = "chongming";
		try {
			//1.加载驱动（把需要的驱动程序加入内存）
			Class.forName("com.mysql.jdbc.Driver");
			 
			//2.取得连接（指定连接哪个数据源、用户名和密码）
			conn = DriverManager.getConnection(sourceURL, user, password);
			return conn;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
	}
}

